<script lang="ts" setup>
import { ref } from 'vue'
import {reactive} from 'vue'
import {inject} from 'vue'

const a = 's1'
// 1. 子组件接收父组件传过来的值
const props = defineProps({
  msg: {
    type:String,default: '我是message'
  },
  total: {
    type: Number,default:1
  }
})

const count = ref(0)
// 2、子组件触发父组件的方法
const emit = defineEmits(["back",'go']);
const go:() => void = () =>{
  emit('go',props.total + 1)
}
const back: ()=> void =() =>{
  emit('back',props.total - 1)
}

// 子组件接收父组件传过来的值
const childValue = inject('mainValue')
childValue.value = 10


// 子传父
const childNumber = 10
const childFunction = ()=> {
  console.log('子组件的child');
}
</script>

<template>
  <h1>{{total }}</h1>
  <h3>{{a}}</h3>
</template>

<style scoped>
a {
  color: #42b983;
}
</style>